//
//  YQLStatusViewModel.swift
//  YQL_WeiBo
//
//  Created by apple on 2016/11/16.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit

class YQLStatusViewModel: NSObject {
    
    var iconUrl: URL?
    
    var memberImage: UIImage?
    
    var verifiedImag: UIImage?

    var status: YQLStatusModel?{
        //对数据进行进一步的加工
        didSet{
            iconUrl = URL(string: status?.user?.avatar_large ?? "")
            //用户等级处理
            self.dealMemberImage()
            //用户认证处理
            self.dealVerifiedImage()
        }
    }
    
    private func dealVerifiedImage() {
        
        let verified = status?.user?.verified_type ?? -1
        
        switch verified {
        case 0:
            verifiedImag = #imageLiteral(resourceName: "avatar_vip")
        case 2,3,5:
            verifiedImag = #imageLiteral(resourceName: "avatar_enterprise_vip")
        case 220:
            verifiedImag = #imageLiteral(resourceName: "avatar_grassroot")
        default:
            verifiedImag = nil
        }
        
    }
    
    private func dealMemberImage() {
        
        let rank = status?.user?.mbrank ?? 0
        
        if rank > 0 && rank < 7 {
            memberImage = UIImage(named: "common_icon_membership_level\(rank)")
        }
        
    }
    
    
}
